<template>
	<view style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;">
		<image :src="url" mode="scaleToFill"></image>
	</view>
</template>
<script setup>
	import { onPullDownRefresh } from '@dcloudio/uni-app';
	import { ref } from 'vue';
	
	const url=ref(null);
	
	function getData() {
		uni.request({
			url: 'https://api.vvhan.com/api/avatar/rand?type=json',
			method: 'GET',
			success: res => {
				url.value=res.data.url;
			},
			complete: () => {
				uni.stopPullDownRefresh();
				uni.showToast({icon:null,title:'获取图像成功'});
			}
		});
	}
	
	onPullDownRefresh(()=>{
		getData();
	});
	
	getData();
</script>
<style>
</style>
